using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;

namespace IDEInterfaceLibrary
{
    /// <summary>
    /// Class that will create a ROOT project.
    /// 
    /// This could be static, but just because I'm not sure what the future
    /// holds, I'm going to make you create it.
    /// </summary>
    public class CreateROOTProject
    {
        /// <summary>
        /// Actually create the project that will do this build.
        /// </summary>
        /// <param name="cf"></param>
        public static void CreateProject(ROOTBuildConfig cf, MSVCSolution sol, UIHierarchy hr)
        {
            ROOTProject rp = new ROOTProject(cf.Directory, cf.ProjectName, sol);

            ///
            /// Add all the files we can find to the project itself...
            /// 

            rp.AddFileProgress += new ROOTProject.AddFileProgressCallback(delegate(string dirname, int depth, int count, int max_count)
            {
                OnAddFileProgress(dirname, depth, count, max_count);
            });

            rp.AddFiles("Source Files", cf.Directory, hr);
        }
        /// <summary>
        /// Callback for status
        /// </summary>
        /// <param name="dir_name">directory we are currently working on</param>
        /// <param name="depth">how many levels down we are</param>
        /// <param name="number">The # directory in the current level we are working on</param>
        /// <param name="total_number">how many directories there are in this level</param>
        public delegate void AddFileProgressCallback(string dir_name, int depth, int number, int total_number);

        public static event AddFileProgressCallback AddFileProgress;

        static void OnAddFileProgress(string dir_name, int depth, int number, int max_number)
        {
            if (AddFileProgress != null)
            {
                AddFileProgress(dir_name, depth, number, max_number);
            }
        }
    }
}
